home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld: Complete Mac Interactive
/
Macworld Complete Mac Interactive CD)(1994).iso
/
The Best of BMUG
/
Utilities
/
Text and Speech
/
Alpha.5.76
/
Tcl
/
SystemCode
/
menus.tcl
< prev
next >
Wrap
Text File
|
1994-03-15
|
7KB
|
411 lines
# A few useful routines.
proc makeMenuPermanent {menu} {
global permanentMenus
set permanentMenus($menu) 1
}
if {[catch {set renamedRemove}]} {
rename removeMenu oldRemoveMenu
set renamedRemove 1
}
proc removeMenu {name} {
global permanentMenus
if {![catch {set permanentMenus($name)}]} return
oldRemoveMenu $name
}
# My menus.
menu -n File -p fileMenuProc {
"/Nnew"
"/Oopen…"
"/Wclose"
{menu -n fileSets {
{menu -n choose -p changeFileSet {}}
{menu -n files {}}
"createFileset…"
"dumpFileset…"
"(-"
"findTag"
"createTagFile"}}
"(-"
"/Ssave"
"saveAs…"
"revert"
"(-"
"/Yshell"
"(-"
"pageSetup…"
"/Pprint…"
"(-"
"/Qquit"
}
proc fileMenuProc {menu item} {
if {$item == "open"} {
findFile
} elseif {$item == "close"} {
killWindow
} else {
$item
}
}
menu -n Edit {
"/Zundo"
"/Dredo"
"/Lload"
"(-"
"/Xcut"
"/Ccopy"
"/Vpaste"
"(-"
"/.pastePop"
"yank"
"/AselectAll"
"clear"
"(-"
{/[shiftLeft}
{/]shiftRight}
"/Bbalance"
}
menu -n Search {
"/Ffind…"
"/GrepeatSearchForward"
"/IrepeatSearchBackward"
"/TfindInNextFile"
"(-"
"/EenterSelection"
"(-"
"/Ureplace"
"/Hreplace&FindAgain"
"replaceAll"
"(-"
"/ gotoLine"
{menu -n namedMarks -p namedMarkProc {
"set…"
"goto…"
"remove…"}}
{menu -n unnamedMarks -p unnamedMarkproc {
"set…"
"exchangePointAndMark"
"/=hilite"}}
{menu -n markStack -p markMenuProc { "push" "pop"}}
}
proc namedMarkProc {menu item} {
switch $item {
"set" {setNamedMark}
"goto" {gotoNamedMark}
"remove" {removeNamedMark}
}
}
proc unnamedMarkproc {menu item} {
switch $item {
"set" {setMark}
"exchangePointAndMark" {exchangePointAndMark}
"hilite" {markHilite}
}
}
proc markMenuProc {menu item} {
switch $item {
"push" {pushMark}
"pop" {popMark}
}
}
menu -n Utilities {
"longMenus"
{menu -n fileUtils {
"insertFile…"
"(-"
"fileRemove…"
"fileInfo/=…"}}
{menu -n Clips {
"copyNamedClipboard…"
"cutNamedClipboard…"
"pasteNamedClipboard…"}}
"(-"
{menu -n arrange {
"vertically^1"
"horizontally^2"
"tiled^3"
"overlay^4"}}
"zoom//"}
menu -n "Utils" {
"shortMenus"
{menu -n Flags -p editFlag {}}
{menu -n Vars -p editVar {}}
{menu -n fileUtils {
"insertPathName…"
"insertFile…"
"fileRemove…"
"fileInfo…"
"wordCount"}}
"(-"
{menu -n Eval {
"evalCommand/\\"
"evalToText/'"
"execCommand"
"repeatEval"
"iterationCount"}}
{menu -n KbdMacros {
"startKeyboardMacro"
"endKeyboardMacro"
"executeKeyboardMacro"
"dumpMacro"}}
"(-"
"spellcheckWindow"
"selectParagraph"
{menu -n NamedClipboards -p namedClipMenuProc {"copy" "cut" "paste"}}
}
proc namedClipMenuProc {menu item} {
switch $item {
"copy" "copyNamedClipboard"
"cut" "cutNamedClipboard"
"paste" "pasteNamedClipboard"
}
}
menu -n Mode {
"listBindings"
"describeBinding"
{menu -n asciiEtc {
"keyCode"
"keyAscii"
"getAscii"
"insertAscii"}}
"(-"
"setFontsTabs…"
{menu -n Colors {
"foreColor"
"backColor"
"dumpColors"}}
"(-"
{menu -m -n switchTo -p switchProc {
"/`MacMiNT"
"THINK Project Manager"
"MPW Shell"
"Versaterm PRO"
"MacLayers"}}
"toolserverShell"
"(-"
"loadElectricAlias"
}
# ==== NOTE: rectMarkHilite, onespace, centerRedraw, doTab
menu -n Convert {
"fillRegion"
"fillParagraph"
"wrapRegion"
"wrapParagraph"
"joinRegion"
"sortLines"
"matchingLines"
"(-"
"zapInvisibles"
"tabsToSpaces"
"spacesToTabs"
"(-"
{menu -n Strings {
"insertPrefix"
"insertSuffix"
"removePrefix"
"removeSuffix"
"setPrefix"
"setSuffix"}}
{menu -n Comment {
"transposeChars"
"transposeWords"
"commentBox"
"uncommentBox"}}
"(-"
{menu -n Filters {
"replaceInRegion"
"filterLines"
"filterParagraphs"
"sortParagraphs"
"fillRegionByPar"
"lineToParagraph"
"paragraphToLine"}}
"downcaseRegion"
"upcaseRegion"
}
# Real Kludge
proc helpMenuProc {menu item} {
global HOME helpMenu
if {$menu == $helpMenu} {
edit -r -m $HOME:Help:$item
} else {
edit -r -m $HOME:Help:$menu:$item
}
}
proc strip {arg} {
if {[regsub -all {\\([][\{\}])} $arg {\1} v]} {return $v}
return $arg
}
# proc buildHelpMenu {f} {
# global helpArr helpMenu
# if {[file isfile $f]} { return [file tail $f] }
#
# set sub ""
# set subd ""
# foreach s [glob $f:*] {
# if {[string match "*~" $s]} continue
# set res [buildHelpMenu $s]
# if {[string match "menu*" $res]} {
# lappend subd $res
# } else {
# lappend sub $res
# }
# }
# set title [file tail $f]
# if {$title == "Help"} {set title $helpMenu}
# list menu -n $title -m -p "helpMenuProc" [concat $sub $subd]
# }
# catch {eval [buildHelpMenu $HOME:Help]}
menu -n $helpMenu -m -p helpMenuProc {
"Intro"
"(-"
"Alpha Commands"
"Tcl Commands"
"(-"
"Customizing"
"Debugging"
"Default Key Bindings"
"Default Key Bindings 2"
"electricAlias Help"
"LaTeX Help"
"Regular Expressions"
"Shells"
"Tcl Library - auto-loading"
"Tcl Mailing List"
"XTCLs"
}
proc switchProc {menu name} {
switchTo $name
}
proc colorMenuProc {menu item} {
if {$item == "removeColors"} {
removeColors
return
}
set one [getPos]
if {[set two [selEnd]] == $one} {
set two [getMark]
if {$two < $one} {
set temp $two
set two $one
set one $temp
}
}
colorize $one $two $item
}
menu -n $winMenu -p menuWin {
{menu -n arrange {
"vertically^1"
"horizontally^2"
"tiled^3"
"overlay^4"}}
{menu -n colors -p colorMenuProc {
"black"
"blue"
"cyan"
"green"
"magenta"
"red"
"white"
"yellow"
"(-"
"removeColors"
}}
"(-"
"//zoom"
"iconify"
"dispFullName"
"toggleScrollbar"
"(-"
"nextWindow"
"swapWithNext"
"/;chooseAWindow"
"prevWindow"
"closeAll"
"saveAll"
"(-"
}
# We may be reloading, so add whatever windows we have
if {[info exists winNameToNum]} {
set nms [array names winNameToNum]
foreach name $nms {
if {$fullNames} {
set item $name
} else {
regexp {[^:]*$} $name item
}
set num $winNameToNum($name)
if {$num < 10} {
addMenuItem -m Wins /$num$item
} else {
addMenuItem -m Wins $item
}
}
}
insertMenu "File"
insertMenu "Edit"
insertMenu "Search"
insertMenu "Utils"
insertMenu "Mode"
enableMenuItem NamedClipboards pasteNamedClipboard off
insertMenu "Convert"
insertMenu $winMenu
catch {insertMenu $helpMenu}
proc shortMenus {} {
global winMenu
removeMenu "Utils"
removeMenu "Mode"
removeMenu "Convert"
removeMenu $winMenu
insertMenu "Utilities"
}
proc longMenus {} {
global winMenu
removeMenu "Utilities"
insertMenu "Utils"
insertMenu "Mode"
insertMenu "Convert"
insertMenu $winMenu
}